@echo off

if not "%AVEVA_DESIGN_EXE%"=="" goto exeok
set AVEVA_DESIGN_EXE=%~dp1
:exeok

if not "%pmllib%"=="" goto pmlok
set pmllib=%AVEVA_DESIGN_EXE%pmllib\
:pmlok

if not "%PMLUI%"=="" goto uiok
set PMLUI=%AVEVA_DESIGN_EXE%PMLUI\
:uiok

if not "%AVEVA_DESIGN_PLOTS%"=="" goto plotsok
set AVEVA_DESIGN_PLOTS=%PMLUI%plots\
:plotsok

if not "%AVEVA_APPLICATION_DATA%"=="" goto appdatok
set AVEVA_APPLICATION_DATA=C:\Users\Public\Documents\AVEVA\Administration\Data1.6.0\
:appdatok

if not "%AVEVA_DESIGN_DFLTS%"=="" goto dfltsok
set AVEVA_DESIGN_DFLTS=D:\AVEVA\Administration\Data1.6.0\DFLTS\
:dfltsok

if "%temp%"=="" goto wkok
if not "%AVEVA_DESIGN_WORK%"=="" goto wkok
set AVEVA_DESIGN_WORK=%temp%\
:wkok

if not "%AVEVA_DESIGN_USER%"=="" goto userok
set AVEVA_DESIGN_USER=D:\AVEVA\USERDATA\
if not "%AVEVA_DESIGN_ACAD%"=="" set AVEVA_DESIGN_USER=%AVEVA_DESIGN_USER%\acad%AVEVA_DESIGN_ACAD%
:userok

if not "%AVEVA_DESIGN_REP_DIR%"=="" goto repok
set AVEVA_DESIGN_REP_DIR=%PMLUI%reports\
:repok

if not "%plotcadc%"=="" goto plotok
set plotcadc=%CommonProgramFiles(x86)%AVEVA Shared\plot\plot.exe
:plotok

if not "%cadc_plot_dir%"=="" goto cplotok
set cadc_plot_dir=%plotcadc%
:cplotok

if not "%cadc_ipcdir%"=="" goto ipcok
set cadc_ipcdir=null
if exist "%AVEVA_DESIGN_EXE%daemon_file" set cadc_ipcdir=%AVEVA_DESIGN_EXE%
:ipcok

if not "%AVEVA_DESIGN_HELP_DIR%"=="" goto phdok
set AVEVA_DESIGN_HELP_DIR=%AVEVA_DESIGN_EXE%Documentation\
:phdok

if not "%MDS_SUPPORT_CONFIG_LOCATION%"=="" goto mdscok
set MDS_SUPPORT_CONFIG_LOCATION=%~df1
echo MDS_SUPPORT_CONFIG_LOCATION set to %MDS_SUPPORT_CONFIG_LOCATION%
:mdscok

set path=%path%;%AVEVA_DESIGN_EXE%;%AVEVA_DESIGN_EXE%dars;%AVEVA_DESIGN_EXE%autodraftACAD;%AVEVA_DESIGN_PLOTS%
echo path set to %path%

rem -----------------------------------------------
rem Set Supplied Project Environment Variables.
rem Each project has its own evars batch file
rem contained in the Project folder.
rem -----------------------------------------------

if not "%projects_dir%"=="" goto prjok
set projects_dir=D:\AVEVA\Projects\E3D2.1\
:prjok
for %%x in ("%projects_dir%\") do set projects_dir=%%~dpsx

rem Aveva Project calls have now moved to custom_evars.bat. See bottom of file for call to this new evars file.

rem ---------------------------------------------
rem Set evars for MDS
rem this sets all the mds specific evars
rem ---------------------------------------------

set mdsplots=%PMLUI%des\mds\plot\
set licadmdsexe=C:\ThirdParty\Licad\LICAD\LICAD_MDS.exe
set pslmdsexe=C:\ThirdParty\PSL\PSLDesigner\PSDesigner.exe
set cplmdsexe=C:\ThirdParty\WH4\WH4win.exe

rem MDS Project calls have now moved to custom_evars.bat. See bottom of file for call to this new evars file.

rem ---------------------------------------------
rem Set evars for ABA
rem this sets all the aba specific evars
rem ---------------------------------------------

if not exist "%pmllib%aba\" goto noaba
  set AVEVA_DESIGN_ABA_LOG=%AVEVA_DESIGN_USER%logFiles\
  set AVEVA_DESIGN_ABA_HYPER=%AVEVA_DESIGN_USER%hyperplantFiles\
  set AVEVA_DESIGN_ABA_PLOT=%AVEVA_DESIGN_USER%plotFiles\
  set AVEVA_DESIGN_ABA_BATCH=%AVEVA_DESIGN_USER%batchFiles\
  set AVEVA_DESIGN_ABA_REPORT=%AVEVA_DESIGN_USER%reportFiles\
  set AVEVA_DESIGN_ABA_DATA=%AVEVA_DESIGN_EXE%asso_products\aba\data\
  set AVEVA_DESIGN_LOG=%AVEVA_DESIGN_USER%AvevaAbaLog.txt
  set AVEVA_DESIGN_LOG_OPT=MDBMODSWEXPUNGECOMMDB
:noaba

rem ---------------------------------------------
rem Set evars for Pipe Stress Interface
rem this sets all the psi specific evars
call \\10.142.3.105\AM_Server\Projects\CMHI282-3\evarsCMHI282.bat



rem ---------------------------------------------

if not exist "%pmllib%psi\" goto nopsi
  set sampsi=%projects_dir%AvevaPlantSample\sampsi\
:nopsi

set AVEVA_DESIGN_EXE=%~dp1;
echo AVEVA_DESIGN_EXE set to %AVEVA_DESIGN_EXE%
for %%x in ("%pmllib%\") do set pmllib=%%~dpsx
echo pmllib set to %pmllib%
for %%x in ("%PMLUI%\") do set PMLUI=%%~dpsx
echo PMLUI set to %PMLUI%
for %%x in ("%AVEVA_DESIGN_REP_DIR%\") do set AVEVA_DESIGN_REP_DIR=%%~dpsx
echo AVEVA_DESIGN_REP_DIR set to %AVEVA_DESIGN_REP_DIR%
for %%x in ("%AVEVA_DESIGN_PLOTS%\") do set AVEVA_DESIGN_PLOTS=%%~dpsx
echo AVEVA_DESIGN_PLOTS set to %AVEVA_DESIGN_PLOTS%
for %%x in ("%AVEVA_DESIGN_USER%\") do set AVEVA_DESIGN_USER=%%~dpsx
echo AVEVA_DESIGN_USER set to %AVEVA_DESIGN_USER%
for %%x in ("%AVEVA_DESIGN_DFLTS%\") do set AVEVA_DESIGN_DFLTS=%%~dpsx
echo AVEVA_DESIGN_DFLTS set to %AVEVA_DESIGN_DFLTS%
for %%x in ("%AVEVA_DESIGN_WORK%\") do set AVEVA_DESIGN_WORK=%%~dpsx
echo AVEVA_DESIGN_WORK set to %AVEVA_DESIGN_WORK%
for %%x in ("%AVEVA_DESIGN_HELP_DIR%\") do set AVEVA_DESIGN_HELP_DIR=%%~dpsx
echo AVEVA_DESIGN_HELP_DIR set to %AVEVA_DESIGN_HELP_DIR%
for %%x in ("%plotcadc%") do set plotcadc=%%~dfx
echo plotcadc set to %plotcadc%
for %%x in ("%cadc_plot_dir%\") do set cadc_plot_dir=%%~dpsx
echo cadc_plot_dir set to %cadc_plot_dir%
for %%x in ("%cadc_ipcdir%\") do set cadc_ipcdir=%%~dpx
echo cadc_ipcdir set to %cadc_ipcdir%

REM MDS
for %%x in ("%mdsplots%\") do set mdsplots=%%~dpsx
echo mdsplots set to %mdsplots%
for %%x in ("%licadmdsexe%") do set licadmdsexe=%%~dfsx
echo licadmdsexe set to %licadmdsexe%
for %%x in ("%pslmdsexe%") do set pslmdsexe=%%~dfsx
echo pslmdsexe set to %pslmdsexe%
for %%x in ("%cplmdsexe%") do set cplmdsexe=%%~dfsx
echo cplmdsexe set to %cplmdsexe%
REM ABA
for %%x in ("%AVEVA_DESIGN_ABA_LOG%\") do set AVEVA_DESIGN_ABA_LOG=%%~dpsx
echo AVEVA_DESIGN_ABA_LOG set to %AVEVA_DESIGN_ABA_LOG%
for %%x in ("%AVEVA_DESIGN_ABA_HYPER%\") do set AVEVA_DESIGN_ABA_HYPER=%%~dpsx
echo AVEVA_DESIGN_ABA_HYPER set to %AVEVA_DESIGN_ABA_HYPER%
for %%x in ("%AVEVA_DESIGN_ABA_PLOT%\") do set AVEVA_DESIGN_ABA_PLOT=%%~dpsx
echo AVEVA_DESIGN_ABA_PLOT set to %AVEVA_DESIGN_ABA_PLOT%
for %%x in ("%AVEVA_DESIGN_ABA_BATCH%\") do set AVEVA_DESIGN_ABA_BATCH=%%~dpsx
echo AVEVA_DESIGN_ABA_BATCH set to %AVEVA_DESIGN_ABA_BATCH%
for %%x in ("%AVEVA_DESIGN_ABA_REPORT%\") do set AVEVA_DESIGN_ABA_REPORT=%%~dpsx
echo AVEVA_DESIGN_ABA_REPORT set to %AVEVA_DESIGN_ABA_REPORT%
for %%x in ("%AVEVA_DESIGN_ABA_DATA%\") do set AVEVA_DESIGN_ABA_DATA=%%~dpsx
echo AVEVA_DESIGN_ABA_DATA set to %AVEVA_DESIGN_ABA_DATA%
for %%x in ("%AVEVA_DESIGN_LOG%\") do set AVEVA_DESIGN_LOG=%%~dpsx
echo AVEVA_DESIGN_LOG set to %AVEVA_DESIGN_LOG%

for %%x in ("%common_tools%\") do set common_tools=%%~dpsx
echo common_tools set to %common_tools%
REM PSI
for %%x in ("%sampsi%\") do set sampsi=%%~dpsx
echo sampsi set to %sampsi%

rem ----------------------------------------------------------------
rem Add SDNF Interface variables
rem ----------------------------------------------------------------
set SDNFMAIN=%AVEVA_DESIGN_INSTALLED_DIR%
if exist "%SDNFMAIN%SDNF_env.bat" call "%SDNFMAIN%SDNF_env.bat"

rem ----------------------------------------------------------------
rem Call custom_evars.bat to set up projects or overwriting settings.
rem ----------------------------------------------------------------
if exist "%projects_dir%custom_evars.bat" call "%projects_dir%custom_evars.bat"

rem ----------------------------------------------------------------
rem Add AVEVA-bocad Interface variables
rem ----------------------------------------------------------------
set BOCMAIN=D:\AVEVA\Administration1.6.0\
set BOCDATA=C:\Users\Public\Documents\AVEVA\Administration\Data1.6.0\

:eof

call \\10.142.3.109\AM_Server\Projects\2ku\STD_CMIH\evarsSTD_CMIH.bat
call \\10.142.3.103\AM_Server\Projects\CMHI289\evarsCMHI289.bat
call \\10.142.3.101\AM_Server\Projects\CMHI282\evarsCMHI282.bat
call \\10.142.3.101\AM_Server\Projects\CMHI282-3\evarsCMHI282.bat
call \\10.142.3.147\AM_Server\Projects\CMHI283\evarsCMHI283.bat
